<!-- D:\project\app\ydz-app-uniapp\static\images\mine -->
<template>
	<view class="pagebody" :style="{ 'min-height': maxHeight }">
		<view class="topbox">
			<view class=" align-center">
				<view class=" flex-row align-center">
					<image @click="backpage" src="@/static/images/login/leftjt.png" alt=""
						style="width: 48rpx;height: 48rpx;"></image>
				</view>
				<view class="color303b39 fz40 fwbold" style="margin-left: 263rpx;">
					基本信息
				</view>
			</view>
		</view>

		<view class="bgfff" style="padding: 0 24rpx;border-radius: 0 0 40rpx 40rpx;">
			<view @click="totx" class=" align-center justify-between" style="height: 154rpx;">
				<view class="fz30" style="color: #576260;">
					头像
				</view>
				<view class="flex-row-center">
					<img :src="avatar" style="width: 90rpx;height: 90rpx;border-radius: 50%;" alt="" />
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view @click="updateother(4)" class=" align-center justify-between"
				style="height: 112rpx; border-top: 1rpx solid #D7DDDC;">
				<view class="fz30" style="color: #576260;">
					昵称
				</view>
				<view class="flex-row-center color303b39 fz32">
					<view class="lineclamp1" style="max-width: 410rpx;">
						{{user.nickName}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view class=" align-center justify-between" @click="sexshow = true"
				style="height: 112rpx; border-top: 1rpx solid #D7DDDC;">
				<view class="fz30" style="color: #576260;">
					性别
				</view>
				<view class="flex-row-center fz32">
					<u-select v-model="sexshow" mode="single-column" :list="sexlist" @confirm="sexconfirm"></u-select>
					<view class="lineclamp1" style="max-width: 410rpx;" :style="{color:sex?'#303B39':'#7E8987'}">
						{{ sex?sex:'请选择您的性别'}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view class=" align-center justify-between" @click="economizeshow = true"
				style="height: 112rpx; border-top: 1rpx solid #D7DDDC;">
				<view class="fz30" style="color: #576260;">
					您所在省市
				</view>
				<view class="flex-row-center fz32">
					<u-select v-model="economizeshow" mode="single-column" :list="economizelist"
						@confirm="confirmeconomize"></u-select>
					<u-select v-model="marketshow" mode="single-column" :list="marketlist"
						@confirm="marketconfirm"></u-select>
					<view class="lineclamp1" style="max-width: 410rpx;" :style="{color:address?'#303B39':'#7E8987'}">
						{{ address?address:'请选择您所在的省市'}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view class=" align-center justify-between" @click="todisease"
				style="height: 112rpx; border-top: 1rpx solid #D7DDDC;">
				<view class="fz30" style="color: #576260;">
					科室疾病
				</view>
				<view class="flex-row-center fz32">
					<view class="lineclamp1" style="max-width: 410rpx;" :style="{color:disease?'#303B39':'#7E8987'}">
						{{ disease?disease:'请选择您的科室疾病'}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
		</view>

		<view class="bgfff mt16" style="padding: 0 24rpx;border-radius:40rpx;">
			<view class=" align-center justify-between" style="height: 112rpx; padding-top: 10rpx;">
				<view class=" fz36 fwbold color303b39" style="">
					其他信息
				</view>

			</view>
			<view @click="updateother(1)" class=" align-center justify-between" style="height: 112rpx; ">
				<view class="fz30" style="color: #576260;">
					正在服用的药品
				</view>
				<view class="flex-row-center color303b39 fz32 ">
					<view class="lineclamp1" style="max-width: 410rpx;">
						{{userDocument.drugName}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view @click="updateother(2)" class=" align-center justify-between" style="height: 112rpx; ">
				<view class="fz30" style="color: #576260;">
					正在使用的疗法
				</view>
				<view class="flex-row-center color303b39 fz32 ">
					<view class="lineclamp1" style="max-width: 410rpx;">
						{{userDocument.therapy}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
			<view @click="updateother(3)" class=" align-center justify-between" style="height: 112rpx; ">
				<view class="fz30" style="color: #576260;">
					目前治疗效果
				</view>
				<view class="flex-row-center color303b39 fz32 ">
					<view class="lineclamp1" style="max-width: 410rpx;">
						{{userDocument.treatmentEffect}}
					</view>
					<image src="../../static/images/mine/rightimg.png"
						style="width: 12rpx;height: 22rpx;margin-left: 16rpx;" mode=""></image>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getAreas,
		editdocument
	} from '@/api/api.js'
	import store from "@/store"
	import {
		getInfo,

	} from '@/api/login'
	import FixedFoot from '../../layouts/fixedfoot.vue';
	export default {
		components: {
			FixedFoot,
		},
		onLoad() {
			// 获得屏幕最大高度
			let systemInfo = uni.getSystemInfoSync();
			this.maxHeight = systemInfo.windowHeight + "px";
		},
		data() {
			return {
				maxHeight: '',
				list: [],
				user: {},
				userDocument: {},
				avatar: store.getters.avatar,
				sex: '',
				sexlist: [{
					label: '男',
					value: 0
				}, {
					label: '女',
					value: 1
				}],
				sexshow: false,
				address: '',
				economizeshow: false,
				economizelist: [],
				economize: '',
				economizevalue:0,
				marketshow: false,
				market: '',
				marketlist: [],
				marketvalue:0,
				disease: '',
				
			}
		},
		created() {
			this.getAreaslist()
		},
		mounted() {},
		onShow() {
			this.getuser()
			uni.$on('returnavatar', () => {
				//触发更新后
				this.changeavatar()
			})
		},

		methods: {
			updateother(typeid) {
				uni.navigateTo({
					url: '/pages/mine/updateother?type=' + typeid
				})
			},
			totx() {
				uni.navigateTo({
					url: '/pages/mine/avatar/index'
				})
			},
			backpage() {
				uni.navigateBack({
					delta: 1
				});
			},
			getuser() {
				getInfo().then(res => {
					this.user = res.user
					this.userDocument = res.userDocument
					if (res.user.sex == 1) {
						this.sex = '女'
					} else {
						this.sex = '男'
					}
					this.address = res.userDocument.provinceName + res.userDocument.cityName
					this.disease = res.userDocument.departmentName+res.userDocument.diseaseName
				})

			},
			todetail(item) {
				uni.navigateTo({
					url: '/pages/forum/forumdetail?id=' + item.invitationId
				})
			},
			sexconfirm(e) {
				this.sex = e[0].label
				let data = {
					sexType:e[0].value
				}
				editdocument(data).then(res=>{
					this.getuser()
				})
			},
			changeavatar() {
				this.avatar = store.getters.avatar
			},
			getAreaslist() {
				getAreas().then(res => {
					let arr = res.rows
					arr.forEach(item => {
						item.label = item.districtName
						item.value = item.districtId
					})
					this.economizelist = arr
				})
			},
			confirmeconomize(e) {
				this.economize = e[0].label
				this.economizevalue = e[0].value
				this.market = ''
				let result = this.economizelist.filter(item => item.districtId === e[0].value);
				let arr = result[0].subordinates
				arr.forEach(item => {
					item.label = item.districtName
					item.value = item.districtId
				})
				this.marketlist = arr
				this.marketshow = true
			},
			marketconfirm(e){
				this.market = e[0].label
				this.marketvalue = e[0].value
				let data = {
					provinceId:this.economizevalue,
					cityId:this.marketvalue
				}
				editdocument(data).then(res=>{
					this.getuser()
				})
			},
			todisease(){
				uni.navigateTo({
					url: '/pages/knowledge/disease?setother=1'
				})
			}

		},

	}
</script>

<style lang="scss" scoped>
	.pagebody {
		padding-bottom: 136rpx;
		background: #F0F6F5;

		.topbox {
			height: 88rpx;
			background: #fff;
			padding: 20rpx 24rpx;
		}



	}
</style>